//
//  NSString+nonce.m
//  AccountEasy
//
//  Created by 黄志刚 on 2020/8/18.
//  Copyright © 2020 AccountEasy. All rights reserved.
//

#import "NSString+nonce.h"

@implementation NSString (nonce)

// 随机生成字符串(由大小写字母、数字组成)
+ (NSString *)random: (int)len {
    char ch[len];
    for (int index=0; index<len; index++) {
        
        int num = arc4random_uniform(75)+48;
        if (num>57 && num<65) { num = num%57+48; }
        else if (num>90 && num<97) { num = num%90+65; }
        ch[index] = num;
    }
    
    return [[NSString alloc] initWithBytes:ch length:len encoding:NSUTF8StringEncoding];
}

@end
